package main

import (
	"flag"
	"fmt"
	"log"
	"os"
	"syproxy/breaking/client"
	"syproxy/breaking/server"
)

func init() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, `syproxy version: syproxy/1.0.0
Usage: syproxy [-mod] [-inner] [-outer] [-auth]

Options:
`)
		flag.PrintDefaults()
	}
}

func main() {
	mod := flag.String("mod", "server", "The mod is server and client, default is server")
	inner := flag.String("inner", "0.0.0.0:8085", "Local address")
	outer := flag.String("outer", "127.0.0.1:8086", "Remote address")
	auth := flag.String("auth", "123456", "The server auth client's token")

	flag.Parse()

	if *mod == "server" {
		log.Printf("The server start! inner: %s, outer: %s, auth: %s", *inner, *outer, *auth)
		server.Run(*inner, *outer, *auth)
	} else if *mod == "client" {
		log.Printf("The client start! inner: %s, outer: %s, auth: %s", *inner, *outer, *auth)
		client.Run(*outer, *inner, *auth)
	} else {
		fmt.Print("The mod is only choose between server or client")
	}
}
